//
//  BaseCollectionViewCellForNews.m
//  MY Project For Sport
//
//  Created by dllo on 16/1/27.
//  Copyright © 2016年 dilo. All rights reserved.
//

#import "BaseCollectionViewCellForNews.h"
#import <DKNightVersion.h>

#define WIDTH self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height

@interface BaseCollectionViewCellForNews ()

@property (nonatomic, retain) UISearchBar *bar;
@end

@implementation BaseCollectionViewCellForNews

- (void)dealloc {
    [_tableView release];
    [_bar release];
    [_button release];
    [super dealloc];
}

-(instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        self.contentView.dk_backgroundColorPicker = DKColorWithRGB (0xffffff, 0x343434);

        [self createSubview];
        
    }
    
    return self;
    
}

/** 创建子视图 */
- (void)createSubview {
    
    // 创建搜索栏
    self.bar = [[UISearchBar alloc] init];
    [self.contentView addSubview:self.bar];
    [_bar release];
    self.bar.placeholder = @"搜索";
    self.bar.dk_backgroundColorPicker = DKColorWithRGB (0xffffff, 0x343434);
    
    self.button = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.contentView addSubview:self.button];
    //[self.button setTitle:@"确定" forState:UIControlStateNormal];
    self.button.backgroundColor = [UIColor clearColor];
    
    
    // 创建 tableview
    self.tableView = [[UITableView alloc] init];
    [self.contentView addSubview:self.tableView];
    [_tableView release];
     
    
}



/** 子视图布局 */
-(void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    
    
    self.bar.frame = CGRectMake(0, 0, WIDTH, HEIGHT / 15);
    self.button.frame = CGRectMake(0, 0, WIDTH, HEIGHT / 15);
    
    
    self.tableView.frame = CGRectMake(0, self.contentView.frame.size.height / 15, self.contentView.frame.size.width, self.contentView.frame.size.height - self.contentView.frame.size.height / 15);
    
}







@end
